<?php
/*	
 * PHP Script to send Xtify 2.x messages with Curl
 * Please read the associated README file on how to use this script
 * 
 * @AndersRetteras, march 2012
 * 
 */
class pushNotification
{
    public $pushMessage;

	// constructor
     public function __construct() {
    	$this->pushMessage = new pushMessage();
     }

	public function getAsJSON(){
		$encoded = json_encode($this->pushMessage);

		return $encoded;
	}

	/* public function createMessage(){
		$content = $this->getAsJSON();
		$url="http://api.xtify.com/1.2/notifconfig/create";
		//$url = 'http://api.xtify.com/2.0/push';
		$ch = curl_init();

		curl_setopt($ch, CURLOPT_URL, $url);

		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, "$content");
		curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); 
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

		$output = curl_exec($ch);
		curl_close($ch);

		return $output;
	} */
	
	
	
}

class pushMessage 
{
	public $notificationConfiguration;
	
	

	public function __construct(){
		//$this->apiKey = "c49e69ac-6549-41d5-82ef-f88fee4bc6dc";
		//$this->appKey = "85dfa915-646c-4112-9c88-d5074b8f78eb";

		/* foreach ($recipients as &$recipient) {
    		array_push($this->xids, $recipient);
		} */

		$this->notificationConfiguration = new notificationConfiguration();
		
	}
}


class notificationConfiguration
{
	public $apiKey="";	
	public $id;
	public $name="";
	public $description="";
	public $appKeys= array();
	//public $xids = array();
	public $hasTags = array();
	/*public $notTags = array();
	public $sendAll = false; */
	public $notificationContent;
	public $notificationLocations;
	public $notificationSchedules;
	public $notificationFrequency;

		public function __construct(){
		//$this->apiKey = "c49e69ac-6549-41d5-82ef-f88fee4bc6dc";
		//$this->appKey = "85dfa915-646c-4112-9c88-d5074b8f78eb";

		/* foreach ($recipients as &$recipient) {
    		array_push($this->xids, $recipient);
		} */

		$this->notificationContent = new content();
		$this->notificationLocations = new notificationLocations();
		$this->notificationSchedules = new notificationSchedules();
		$this->notificationFrequency = new notificationFrequency();

		
	}
}
class content {
	public $android;
	public $iphone;
	public $blackberry;
	
	/* public $subject="";
	public $message="";
	public $action;
	public $rich;
	public $payload;
	public $sound="";
	public $badge="";
	public $actionCategories=""; */
	//public $groupId="";

	public function __construct(){
		
		$this->android = new cnt_android();
		$this->iphone = new cnt_iphone();
		$this->blackberry = new cnt_blackberry();
		
		
	}
}

class cnt_android {
          public $message="";
          public $messageTitle="";
            public $actionIntent="";
            public $actionCategories="";
            public $actionData="";
            public $groupId="";
            public $url="";
            public $urlLabel="";
            public $actionType="LAUNCH_APP";
            public $collectPollingData=FALSE;
            public $showNotificationScreen=TRUE;
        }

class cnt_iphone
{
	public $message="";
    public $badge="";
    public $sound="";
             public $actionButtonLabel="";
			 public $actionType="NONE";
             public $dataItems=array();
             public $actionUrl="";
             public $richSubject="";
             public $richContent="";          
             public $richActionType="NONE";   
             public $richActionLabel="";
             public $richActionData="";		
}	
	
class cnt_blackberry {
	public $message="";
	}

class notificationLocations {

public $location = array (

	"name"=>"",
"description"=>"",
"address"=>"",
"lat"=>"",
"lng"=>"",
"radius"=>""
);

}

class notificationSchedules {
public $schedule = array(
"startDate"=>"mm/dd/yyyy",
"endDate"=>"mm/dd/yyyy",
"startTime"=>"hh:mm",
"endTime"=>"hh:mm",
"daysOfWeek"=>"0,1,2,3,4,5,6"
	);	

}


class notificationFrequency {
public $maxNotificationsPerUser;
public $minimumMinutesBetweenNotifications;

}
?>